<template>
	<div>


		<el-row>
			<el-col :span="1" class="labelCol">
				<p class="labelText">处理状态:</p>
			</el-col>

			<el-col :span="3">
				<el-select v-model="allotStatus" size='small' placeholder="请选择" clearable>
					<el-option v-for="item in  allotStatusCombo" :label="item.label" :value="item.value">
					</el-option>
				</el-select>
			</el-col>
			<el-col :span="1" class="labelCol">
				<p class="labelText">任务大类:</p>
			</el-col>
			<el-col :span="3">
				<el-select v-model="taskPtype" size='small' placeholder="任务大类" clearable @change="taskTypeChange">
					<el-option v-for="item in  taskPTypeCombo" :label="item.label" :value="item.value">
					</el-option>
				</el-select>
			</el-col>
			<el-col :span="1" class="labelCol">
				<p class="labelText">任务小类:</p>
			</el-col>
			<el-col :span="3">
				<el-select v-model="taskCtype" size='small' placeholder="任务小类" clearable>
					<el-option v-for="item in  taskCTypeCombo" :label="item.label" :value="item.value">
					</el-option>
				</el-select>
			</el-col>
			<el-col :span="1" class="labelCol">
				<p class="labelText">SA姓名:</p>
			</el-col>
			<el-col :span="3">
				<el-select v-model="deal" size='small' placeholder="SA" clearable>
					<el-option v-for="item in  sa" :label="item.label" :value="item.value">
						<span style="float: left">{{ item.label }}</span>
						<span style="float: right; color: #FF0000; font-size: 13px">
							<el-tag type="danger">{{ item.sum }}</el-tag>
						</span>
					</el-option>
				</el-select>
			</el-col>
			<el-col :span="1" class="labelCol">
				<p class="labelText">任务标题:</p>
			</el-col>
			<el-col :span="3">
				<el-input size="small" v-model="taskTitle" placeholder="任务标题"></el-input>
			</el-col>
		</el-row>
		<el-row>
			<el-col :span="1" class="labelCol">
				<p class="labelText">分配类型:</p>
			</el-col>
			<el-col :span='3'>
				<el-select size="small" v-model="allotType" placeholder="请选择" clearable>
					<el-option v-for="item in typeCombo" :label="item.label" :value="item.value">
					</el-option>
				</el-select>
			</el-col>
			<el-col :span="1" class="labelCol">
				<p class="labelText">分配内容:</p>
			</el-col>
			<el-col :span='3' v-if="allotType != '3'">
				<el-input v-model="allotTypeV" size="small" placeholder="请输入"></el-input>
			</el-col>
			<el-col :span='3' v-if="allotType == '3'">
				<el-select size="small" v-model="allotTypeV" placeholder="请选择" clearable>
					<el-option v-for="item in vinListCombo" :label="item.fileName" :value="item.id">
						<span style="float: left;">{{item.fileName}}</span>
						<el-button type="danger" style="float: right;" size="mini" @click="deleteVIN(item.id)">删除</el-button>
					</el-option>
				</el-select>
			</el-col>
			<el-col :span="4" style="padding-left: 2px">
				<div v-if="allotType == '3'" style="clear: both;float: left">
					<el-upload :action="action" :data="upData" name="upExecl" :on-progress="process" :on-error="error" :on-success="success" v-loading.fullscreen.lock="fullscreenLoading" element-loading-text="数据导入中，请稍后！">
						<el-button size="small" type="primary">点击上传</el-button>
						<span slot="tip">只能上传xlsx文件</span>
					</el-upload>
				</div>
			</el-col>
			<el-col :span="1" class="labelCol">
				<p class="labelText">任务状态:</p>
			</el-col>

			<el-col :span="3">
				<el-select v-model="taskType" size='small' placeholder="请选择" clearable>
					<el-option label="未完成" value="0">
					</el-option>
					<el-option label="已完成" value="1">
					</el-option>
					<el-option label="已关闭" value="2">
					</el-option>
				</el-select>
			</el-col>
			<el-col :span="1" class="labelCol">
				<p class="labelText">选择时间:</p>
			</el-col>
			<el-col :span="3">
				<el-date-picker class="mtn" size="small" style="width:90%!important;" v-model="monthTask" type="month" placeholder="选择月">
				</el-date-picker>
			</el-col>

			<el-col :span="1" class="labelCol">
				<p class="labelText">所属门店:</p>
			</el-col>
			<el-col :span="3">
				<el-select v-model="belongsStoreName" size='small' placeholder="所属门店" multiple clearable>
					<el-option v-for="item in belongsStoreCombo" :label="item.value" :value="item.value">
					</el-option>
				</el-select>
			</el-col>

		</el-row>
		<el-row>
			<el-col :span="1" class="labelCol">
				<p class="labelText">车系:</p>
			</el-col>
			<el-col :span='3'>
				<el-select size="small" v-model="series" placeholder="请选择车系" clearable>
					<el-option v-for="item in seriesComboData" :label="item.label" :value="item.value"></el-option>
				</el-select>
			</el-col>
			<el-col :span="1" class="labelCol" v-if="this.$data.taskPtype=='bx'">
				<p class="labelText">车辆等级:</p>
			</el-col>
			<el-col :span='3' v-if="this.$data.taskPtype=='bx'">
				<el-select size="small" v-model="activeTag" placeholder="请选择等级" clearable>
					<el-option v-for="item in activeTagCombo" :label="item.label" :value="item.value"></el-option>
				</el-select>
			</el-col>

			<el-col :span="8">
				<el-button size="small" type="primary" @click="queryTaskGrid">查询</el-button>

				<el-button v-if="this.$data.queryCompanyId == this.$data.curCompanyId" size="small" type="primary" @click="dealTaskGrid">任务分配</el-button>
				<el-button v-if="this.$data.queryCompanyId == this.$data.curCompanyId" size="small" type="primary" @click="exportTask">导出</el-button>

			</el-col>
		</el-row>
		<!-- 查询条件 -->
		<!-- 任务表格 -->
		<el-row>
			<el-col :span="24">
				<el-table :data="taskGrid.dataList" border @selection-change="handleSelectionChange" :row-class-name="tableRowClassName">
					<el-table-column type="selection" width="60">
					</el-table-column>
					<el-table-column label="类别" width="150">
						<template scope="scope">
							<el-tag type="primary">{{scope.row.typeName}}</el-tag>
						</template>
					</el-table-column>
					<el-table-column label="日期" align="center" width="150">
						<template scope="scope">
							{{scope.row.expectDate}}
						</template>
					</el-table-column>
					<el-table-column prop="vin" label="车架号" width="240">
					</el-table-column>
					<el-table-column prop="plateNum" label="车牌号" width="140">
						<template scope="scope">
							<el-button type="text" v-on:click="plateNumQuery(scope.$index)"> {{scope.row.plateNum}}</el-button>
							<el-badge class="mark" :value="scope.row.cp" />
						</template>
					</el-table-column>
					<el-table-column prop="content" label="任务标题" width="260">
					</el-table-column>
					<el-table-column prop="status" label="用户状态" width="200" :formatter="statusFor">
					</el-table-column>
					<el-table-column prop="uname" label="处理人" width="170">
					</el-table-column>
				</el-table>
				<el-pagination small @current-change="handleCurrentChange" :current-page="CurentPage" :page-sizes="page.pageSizes" :page-size="page.pageSize" layout=" total,prev, pager, next" :total="taskGrid.total">
				</el-pagination>
			</el-col>
		</el-row>
		<!-- 任务表格 结束 -->
		<el-dialog title="请选择人员" v-model="peopleShow">
			<el-row :gutter="24">
				<el-col :span="1" class="labelCol">
					<p class="labelText">姓名:</p>
				</el-col>
				<el-col :span="4">
					<el-input size="small" v-model="uname" placeholder="请输入姓名"></el-input>
				</el-col>
				<el-col :span="10">
					<el-button size="small" type="primary" @click="pageQuery">查询</el-button>

					<el-button size="small" type="primary" @click="peopleMoreSave" v-if="this.$data.multipleSelection.length==0">多人平分</el-button>
				</el-col>
			</el-row>
			<el-table :data="peopleData.dataList" border @selection-change="handlePeopleSelectionChange">
				<el-table-column type="selection" width="60" v-if="this.$data.multipleSelection.length==0">
				</el-table-column>
				<el-table-column type="index" label="序号" width="70"></el-table-column>
				<el-table-column prop="uName" label="姓名"></el-table-column>
				<el-table-column prop="oName" label="部门"></el-table-column>
				<el-table-column prop="uMobile" label="手机号" align="right"></el-table-column>
				<el-table-column prop="rName" label="处理权限"></el-table-column>
				<el-table-column prop="" label="操作" width="120">
					<template scope="scope">
						<el-tooltip effect="light" content="分配" placement="top">
							<el-button type="primary" size="mini" @click.native.prevent="peopleSave(scope.$index)">分配</el-button>
						</el-tooltip>
					</template>
				</el-table-column>
			</el-table>
			<el-pagination small @current-change="handleCurrentChange2" :current-page="CurentPage2" :page-sizes="page.pageSizes" :page-size="page.pageSize" layout=" total,prev, pager, next" :total="peopleData.total">
			</el-pagination>
		</el-dialog>
		<el-dialog title="提示" v-model="allotShow" size="tiny">
			<div>
				<strong style="font-size: 15px;">{{allotmessage}}</strong><br><br>

				<el-radio class="radio" v-model="force" label="false">否</el-radio>
				<!--
				<el-radio class="radio" v-model="force" label="true">是</el-radio><br><br>
					-->
			</div>
			<div v-if="force == 'true'">
				<strong style="font-size: 15px;color: red;">若分配任务中存在已分配任务，此操作将强制更改其处理人员！</strong><br><br>
			</div>
			<div v-if="force == 'false'">
				<strong style="font-size: 15px;">仅分配未分配且未完成的任务，此操作不影响已处理和已分配的任务！</strong><br><br>
			</div>
			<div slot="footer" class="dialog-footer">
				<el-button size="small" @click="allotShow=false">取消</el-button>
				<el-button size="small" type="primary" @click="taskAllot">确认</el-button>
			</div>
		</el-dialog>
	</div>
</template>

<script>
export default {
  data: function() {
    return {
      fullscreenLoading: false,
      curCompanyId: window.localStorage.getItem("companyId"),
      // 区域
      areaCombo2: [],
      // 品牌
      brandCombo: [],
      // 公司
      companyCombo: [],
      // 所属门店
      belongsStoreCombo:[],
      // 查询条件公司ID
      queryCompanyId: window.localStorage.getItem("companyId"),
      // 查询区域
      queryArea: "",
      // 查询品牌
      queryBrand: "",
      action: this.API_ROOT + "/crm/task/upload",
      upData: {
        uid: window.localStorage.getItem("uid"),
        token: window.localStorage.getItem("token")
      },
      allotShow: false, //强制分配选择提示框
      allotmessage: "", //强制分配提示内容
      //
      force: "false", //是否强制分配
      loadingVue: null,
      //查询条件
      // 车系
      seriesComboData: [],
      activeTagCombo: [],
      vinUp: "",
      //vin下拉列表
      vinListCombo: [],
      //查询条件
      allotType: "1",
      allotTypeV: "",
      taskType: "0",
      monthTask: "",
      taskTitle: "",
      series: "",
      activeTag: "",
      inWx: "false",
      belongsStoreName:[], // 所属门店
      //类型
      typeCombo: [
        {
          label: "尾号",
          value: "1"
        },
        {
          label: "尾数",
          value: "2"
        },
        {
          label: "车架号",
          value: "3"
        }
      ],
      //批量分配弹出界面显示
      peopleShow: false,
      //手动拨号的手机号
      telephoneInput: "",
      callFormShow: false,

      /*******查询客户相关数据↓*******/

      //分组数据
      tableDataOrder: {
        total: 0,
        dataList: []
      },
      /*******查询客户相关数据↑*******/

      /******* 任务查询条件*******/
      plateNu: "",
      taskStatus: "",
      page: this.page,
      CurentPage: 1,
      CurentPage2: 1,

      /**************任务列表状态***************/
      taskGrid: {
        total: 0,
        dataList: []
      },

      multipleSelection: [],

      /********维护大类、维护小类字典 开始**/
      //级联选择的值
      parentId: [],
      msgTypeCode: [],

      sa: [],
      /********维护大类、维护小类字典 结束**/
      /********任务字典开始*********/
      taskPtype: "",
      taskCtype: "",
      deal: "",
      //任务状态
      allotStatusCombo: [
        {
          value: "0",
          label: "未分配"
        },
        {
          value: "1",
          label: "已分配"
        }
      ],
      //任务大类
      taskPTypeCombo: [],
      //任务小类
      taskCTypeCombo: [],
      // 保险子类
      bxChild: [],
      // 关爱子类
      gaChild: [],
      // 自定义子类
      zdyChild: [],
      // 流失子类
      lsChild: [],
      // 保养子类
      byChild: [],
      /***********任务字典结束****************/

      /***********流失方向字典结束****************/
      userTagCombo: [],
      /***********维系记录窗口****************/

      //勾选的任务
      changeId: [],
      //选择的车辆是否相同的标识
      changePlantU: false,
      //最近的工单
      work: {
        workOrder: [],
        workItem: []
      },
      //分配状态
      allotStatus: "0",
      //人员
      peopleData: {
        total: 0,
        dataList: []
      },
      //选择人员存储
      peopleSelect: [],
      //姓名查询条件
      uname: "",
      saId: ""
    };
  },
  methods: {
    //删除上次上传VIN分配方案
    deleteVIN: function(id) {
      this.$http({
        method: "POST",
        url: this.API_ROOT + "/crm/task/clean/vinFiles",
        params: {
          id: id
        }
      }).then(
        function(resp) {
          if (resp.data.success) {
            this.$data.allotTypeV = "";
            this.groupVIN();
            this.$message(resp.data.msg);
          }
        },
        function(error) {
          //error
        }
      );
    },
    taskTypeChange: function(value) {
      switch (value) {
      	case "zh":
          this.$data.taskCTypeCombo = this.$data.zhChild;
          this.$data.taskCtype = "";
          break;
        case "by":
          this.$data.taskCTypeCombo = this.$data.byChild;
          this.$data.taskCtype = "";
          break;
        case "bx":
          this.$data.taskCTypeCombo = this.$data.bxChild;
          this.$data.taskCtype = "";
          break;
        case "ga":
          this.$data.taskCTypeCombo = this.$data.gaChild;
          this.$data.taskCtype = "";
          break;
        case "ls":
          this.$data.taskCTypeCombo = this.$data.lsChild;
          this.$data.taskCtype = "";
          break;
        case "qt":
          this.$data.taskCTypeCombo = this.$data.qtChild;
          this.$data.taskCtype = "";
          break;
      }
    },
    process: function() {
      this.$data.fullscreenLoading = true;
      //				this.$data.loadingVue = this.$loading({
      //					fullscreen: true,
      //					text: "正在导入数据，请稍候"
      //				});
    },
    error: function(err, response) {
      this.$message.error(response.data.msg);
      this.$data.fullscreenLoading = false;
    },
    success: function(response) {
      this.$data.fullscreenLoading = false;

      if (response.success) {
        this.$message("上传车架号成功！");
        this.groupVIN();
      } else {
        this.$message.error(response.data.msg);
      }
    },
    //选择人员
    handlePeopleSelectionChange: function(val) {
      this.peopleSelect = val;
    },
    //人员换页
    handleCurrentChange2: function(page) {
      this.$data.CurentPage2 = page;
      this.pageQuery();
    },
    //人员分页查询
    pageQuery: function() {
      this.$http({
        method: "POST",
        url: this.API_ROOT + "/rbac/user/hasQxUser",
        body: this.$data.multipleSelection,
        params: {
          start: this.$data.CurentPage2,
          limit: this.$data.page.pageSize,
          uname: this.$data.uname,
          pcode: this.$data.taskPtype,
          code: this.$data.taskCtype
        }
      }).then(
        function(resp) {
          //success

          resp.data.total = parseInt(resp.data.total);
          this.$data.peopleData = resp.data;
        },
        function(error) {
          //error
        }
      );
    },
    //批量分配按钮
    dealTaskGrid: function() {
      debugger;

      var arr = Array();
      if (this.$data.multipleSelection.length != "0") {
        this.$http({
          method: "POST",
          url: this.API_ROOT + "/rbac/user/hasQxUser",
          body: this.$data.multipleSelection,
          params: {
            start: this.$data.CurentPage2,
            limit: this.$data.page.pageSize,
            pcode: this.$data.taskPtype,
            code: this.$data.taskCtype
          }
        }).then(
          function(resp) {
            resp.data.total = parseInt(resp.data.total);
            this.$data.peopleData = resp.data;
            //						this.pageQuery();
            this.$data.peopleShow = true;
          },
          function(error) {
            // error
          }
        );
      } else {
        this.$http({
          method: "POST",
          url: this.API_ROOT + "/rbac/user/hasQxUser",
          body: arr,
          params: {
            start: this.$data.CurentPage2,
            limit: this.$data.page.pageSize,
            pcode: this.$data.taskPtype,
            code: this.$data.taskCtype
          }
        }).then(
          function(resp) {
            resp.data.total = parseInt(resp.data.total);
            this.$data.peopleData = resp.data;
            //						this.pageQuery();
            this.$data.peopleShow = true;
          },
          function(error) {
            // error
          }
        );
      }
    },
    //确认任务分配
    taskAllot: function() {
      var arr = new Array();
      if (this.$data.multipleSelection.length > 0) {
        arr = this.$data.multipleSelection;
      } else {
        arr = [];
      }
      
      	var mData = {belongsStoreName:[],arr:arr};
    	mData.belongsStoreName = this.$data.belongsStoreName;
      debugger;
      this.$http
        .post(this.API_ROOT + "/crm/task/distTask", mData, {
          params: {
            force: this.$data.force,
            saId: this.$data.saId,
            start: this.$data.CurentPage,
            limit: this.$data.page.pageSize,
            title: this.$data.taskTitle,
            pcode: this.$data.taskPtype,
            code: this.$data.taskCtype,
            taskType: this.$data.taskType,
            deal: this.$data.deal,
            allotstatus: this.$data.allotStatus,
            platenum: this.$data.plateNum,
            allotType: this.$data.allotType,
            allotTypeV: this.$data.allotTypeV,
            series: this.$data.series,
            acTag: this.$data.activeTag,
            inWx: this.$data.inWx
          }
        })
        .then(
          function(resp) {
            this.$message(resp.data.msg);
            this.$data.peopleShow = false;
            this.$data.allotShow = false;
            this.queryTaskGrid();
            this.groupComboF();
          },
          function(error) {
            //error
          }
        );
    },
    //人员分配保存
    peopleSave: function(index) {
      this.$data.force = "false";
      this.$data.saId = this.$data.peopleData.dataList[index].id;
      if (this.$data.multipleSelection.length != 0) {
        this.$data.allotmessage =
          "是否要强制性的将所选择的任务分配给[" +
          this.$data.peopleData.dataList[index].uName +
          "]？";
        this.$data.allotShow = true;
      } else {
        this.$data.allotmessage =
          "是否要强制性的将所查询出的任务分配给[" +
          this.$data.peopleData.dataList[index].uName +
          "]？";
        this.$data.allotShow = true;
      }
    },
    //人员平均分配保存
    peopleMoreSave: function() {
      if (this.$data.peopleSelect.length == 0) {
        this.$message.warning("请选择要分配的人员");
        return;
      }

      var name = "";
      var uids = "";
      for (var i = 0; i < this.$data.peopleSelect.length; i++) {
        if (i == 0) {
          name = this.$data.peopleSelect[i].uName;
          uids = this.$data.peopleSelect[i].id;
        } else {
          name += "," + this.$data.peopleSelect[i].uName;
          uids += "," + this.$data.peopleSelect[i].id;
        }
      }
      this.$data.saId = uids;
      if (this.$data.multipleSelection.length != 0) {
        this.$data.allotmessage = "是否要强制性的将所选择的任务分配给 [" + name + "] ？";
        this.$data.allotShow = true;
      } else {
        this.$data.allotmessage = "是否要强制性的将所查询出的任务分配给[ " + name + "] ？";
        this.$data.allotShow = true;
      }
    },

    //任务状态转换
    statusFor: function(row, column) {
      if (row.status == 1) {
        return "已完成";
      } else if (row.status == 2) {
        return "已关闭";
      } else {
        if (
          row.expectDate <
          this.moment(new Date().toISOString()).format("YYYY-MM-DD")
        ) {
          return "任务已过期，请尽快处理！";
        } else {
          return row.statusName;
        }
      }
    },

    handleSelectionChange: function(val) {
      this.$data.multipleSelection = val;
      //给状态赋初值
      this.$data.changePlantU = true;
      //循环赋值（id）和判断（plateNum）
      for (var i = 0; i < val.length; i++) {
        this.$data.changeId[i] = val[i].id;
        if (val[i].plateNum != val[0].plateNum) {
          this.$data.changePlantU = false;
        }
      }
    },

    tableRowClassName: function(row, index) {
      if (
        row.expectDate <
        this.moment(new Date().toISOString()).format("YYYY-MM-DD")
      ) {
        return "day-row";
      }
      return "";
    },
    handleCurrentChange: function(page) {
      this.$data.CurentPage = page;
      this.queryTaskGrid();
    },

    /***************打开维系记录窗口结束****************/

    /**************任务状态转换结束****************/

    /************************点击车牌号查询**************************************/
    /*************加载任务列表**********/
    plateNumQuery: function(a) {
      this.$data.CurentPage = 1;

      this.$data.taskTitle = this.$data.taskGrid.dataList[a].plateNum;
      this.queryTaskGrid();
    },

    /*************导出任务列表**********/

    exportTask: function() {
      var lodding = this.$loading({
        fullscreen: true,
        text: "正在生成导出数据，请稍候..."
      });
      
     	var mData = {belongsStoreName:[]};
    	mData.belongsStoreName = this.$data.belongsStoreName;
    	
      this.$http({
        method: "POST",
        url: this.API_ROOT + "/crm/task/export/manger/task",body:mData,
        params: {
          start: this.$data.CurentPage,
          limit: this.$data.page.pageSize,
          title: this.$data.taskTitle,
          pcode: this.$data.taskPtype,
          code: this.$data.taskCtype,
          deal: this.$data.deal,
          allotstatus: this.$data.allotStatus,
          platenum: this.$data.plateNum,
          allotType: this.$data.allotType,
          allotTypeV: this.$data.allotTypeV,
          taskType: this.$data.taskType,
          series: this.$data.series,
          acTag: this.$data.activeTag,
          belongsStoreName:this.$data.belongsStoreName,
          inWx: this.$data.inWx,
          month:
            this.moment(new Date(this.$data.monthTask)).format("YYYY-MM") ==
            "Invalid date"
              ? ""
              : this.moment(new Date(this.$data.monthTask)).format("YYYY-MM")
        }
      }).then(
        function(resp) {
          lodding.close();
          if (resp.data.success) {
            window.location.href =
              this.API_ROOT +
              "/base/exp/xlsx?fileId=" +
              resp.data.data +
              "&&fileName=任务分配明细-" +
              this.moment().format("YYYYMM") +
              "&&fileType=xlsx";
          }
          //
        },
        function(error) {
          this.$message({
            type: "error",
            message: "执行导出出错!"
          });
          //error
          lodding.close();
        }
      );
    },
    /*************加载任务列表**********/
    queryTaskGrid: function() {
    	var mData = {belongsStoreName:[]};
    	mData.belongsStoreName = this.$data.belongsStoreName;
    	debugger;
      this.$http({
        method: "POST",
        url: this.API_ROOT + "/crm/task/manger/page",
        body:mData
        ,
        params: {
          start: this.$data.CurentPage,
          limit: this.$data.page.pageSize,
          title: this.$data.taskTitle,
          pcode: this.$data.taskPtype,
          code: this.$data.taskCtype,
          deal: this.$data.deal,
          allotstatus: this.$data.allotStatus,
          platenum: this.$data.plateNum,
          allotType: this.$data.allotType,
          allotTypeV: this.$data.allotTypeV,
          taskType: this.$data.taskType,
          companyId: this.$data.queryCompanyId,
          series: this.$data.series,
          acTag: this.$data.activeTag,
          inWx: this.$data.inWx,
          
          month:
            this.moment(new Date(this.$data.monthTask)).format("YYYY-MM") ==
            "Invalid date"
              ? ""
              : this.moment(new Date(this.$data.monthTask)).format("YYYY-MM")
        }
      }).then(
        function(resp) {
          //success

          resp.data.total = parseInt(resp.data.total);
          this.$data.taskGrid = resp.data;
        },
        function(error) {
          //error
        }
      );
    },

    //加载查询条件分组的下拉数据
    groupComboF: function(roleIds) {
      this.$data.sa = [];
      this.$data.deal = "";
      //加载分组
      this.$http
        .get(this.API_ROOT + "/crm/task/combo", {
          params: {
            //type: roleIds
            companyId: this.$data.queryCompanyId
          }
        })
        .then(
          response => {
            // success callback
            this.$data.sa = response.data;
          },
          response => {
            // error callback
          }
        );
    },
    //获取车架号下拉
    groupVIN: function() {
      this.$http
        .get(this.API_ROOT + "/crm/task/vinFiles", {
          params: {}
        })
        .then(
          response => {
            this.$data.vinListCombo = response.data.data;
          },
          response => {}
        );
    },
    //获取公司信息
    getCompanyInfo: function() {
      //this.$data.data.companyId = ""; //清空单位
      this.$data.queryCompanyId = ""; //清空单位
      this.$data.companyCombo = [];
      debugger;
      this.$http
        .get(this.API_ROOT + "/rbac/dept/all", {
          params: {
            area: this.$data.queryArea,
            brand: this.$data.queryBrand
          }
        })
        .then(resp => {
          this.$data.companyCombo = resp.data.dataList;
          if (this.$data.companyCombo.length > 0) {
            this.$data.queryCompanyId = this.$data.companyCombo[0].id;
          }
        });
    },
    // 获取所有门店
    getBelongsStoreCombo: function() {
      debugger;
      this.$http
        .get(this.API_ROOT + "/rbac/dept/AllDeptStore", {
          params: {}
        })
        .then(resp => {
          this.$data.belongsStoreCombo = resp.data.dataList;
        });
    },
    //获取区域
    getarea: function() {
      debugger;
      this.$http
        .get(this.API_ROOT + "/rbac/dept/area/all", {
          params: {}
        })
        .then(resp => {
          this.$data.areaCombo2 = resp.data.dataList;
        });
    },
    //获取品牌
    getBrand: function() {
      debugger;
      this.$http
        .get(this.API_ROOT + "/rbac/dept/brand/all", {
          params: {}
        })
        .then(resp => {
          this.$data.brandCombo = resp.data.dataList;
        });
    },
    /***
				公司 ID 切换时，获取不同的数据
			*/
    getAreaCombo: function() {
      //huoqu 车系
      this.getSeries();
      //huoqu 人员
      this.groupComboF();
      //加载行政区划
      this.$http
        .get(this.API_ROOT + "/car/base/areaCombo", {
          params: {
            companyId: this.$data.queryCompanyId
          }
        })
        .then(
          response => {
            // success callback
            this.$data.areaCombo = response.data;
          },
          response => {
            // error callback
          }
        );
    },
    getComboGroup: function() {
      //任务状态
      this.$http
        .get(this.API_ROOT + "/base/dict/combo/groups", {
          params: {
            group: "02030601,02030602,by,bx,ga,qt,ls,zh"
          }
        })
        .then(
          response => {
            var combo = response.data;
            this.$data.taskStatusCombo = combo["02030601"];
            this.$data.taskPTypeCombo = combo["02030602"];
            this.$data.bxChild = combo["bx"];
            this.$data.gaChild = combo["ga"];
            this.$data.lsChild = combo["ls"];
            this.$data.zhChild = combo["zh"];
            this.$data.qtChild = combo["qt"];
            this.$data.byChild = combo["by"];
          },
          response => {}
        );
    },

    getSeries: function() {
      this.$http
        .get(this.API_ROOT + "/base/car/combo", {
          params: {
            companyId: this.$data.queryCompanyId
          }
        })
        .then(
          response => {
            // success callback
            this.$data.seriesComboData = response.data;
          },
          response => {
            // error callback
          }
        );
    },
    // 多人均分
    updateMore: function() {}
  },

  /******创建时运行*********/
  created: function() {
    this.getComboGroup(); // 任务状态
   this.getBelongsStoreCombo(); // 获取所有门店
    //加载任务列表
    this.queryTaskGrid();
    //加载查询条件分组的下拉数据
    this.groupComboF();
    //获取部门资源树
    this.groupVIN();
    this.getSeries();
  }
};
</script>
<style>

</style>